<?php
/**
 * Generates an unordered list with featured images, and 
 * an excerpt of length 80 chars embedded.
 *
 * @package Behold
 * @since Behold 1.0.0
 */
 
$the_query = new WP_Query( array( 'posts_per_page' => -1, 'meta_key' => '_thumbnail_id', 'post_type' => 'post' ) );
		if ( have_posts() and ! is_singular() ) :
				$least_one_featured_image = false;
				$counter = 0;
				$total = 0;
				
				while ($the_query->have_posts() ) : $the_query->the_post();
					if ( has_post_thumbnail()) :
						$beholdimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'Beholdthumb', false, '' );
						if ( ! $beholdimage ) :
						  break; # break, if the featured image is not available.
						endif;
						$total++;
					endif;
				endwhile;
				
				rewind_posts();
				while ($the_query->have_posts() ) : $the_query->the_post();
					if ( has_post_thumbnail()) :
						if ( has_post_thumbnail()) :
							$beholdimage = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'Beholdthumb', false, '' );
							if ( ! $beholdimage ) :
							  break; # break, if the featured image is not available.
							endif;
							$counter++;
						endif;
					?>	
					<li class="slide">
					<div class="slider-featured-img">
					<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'Behold' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
					<img alt="Featured image .." src="<?php echo $beholdimage[0]; ?>" />
					</a>
					
					</div>
					<?php $least_one_featured_image = true; # We use this to display the next/prev slider navigator.?>
					<div class="featured-post-details">
						<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'Behold' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title();?></a>
							
						<a class="slider-read-more" href="<?php the_permalink();?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'Behold' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php _e('Read more..','Behold'); ?>
						</a>
						&nbsp;
						<span class="now-showing">
							<?php							
								printf( __( 'Showing %1$s of %2$s featured posts.', 'Behold' ), $counter, $total );							
							?>
						</span>
						
						<?php if ( $least_one_featured_image ) : ?>
							<div id="slider-nav">
								<span id="slider-navigator-left" title="<?php _e("Previous featured post","behold");?> ">
									&larr;
								</span>
							
								<span id="slider-navigator-right" title="<?php _e("Next featured post","behold");?> ">
									&rarr;
								</span>			
							</div>
						<?php endif;?>
					
					</div>
				</li>
				<?php endif; ?>				
			<?php endwhile;  ?>
			
	<?php endif;?>
